package com.it.octoo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@EnableResourceServer
@EnableDiscoveryClient
@SpringBootApplication
public class UserApplication {

	public static void main(String[] args) {
		SpringApplication.run(UserApplication.class, args);
	}

	@RestController
	@RequestMapping("/api")
	class DemoController {

		// 可以匿名访问
		@GetMapping("/public/{id}")
		public String publicResource(@PathVariable long id) {
			return "this is public "+id;
		}

		// 必须经过认证
		@GetMapping("/protect/{id}")
		public String protectResource(@PathVariable long id) {
			return "this is protect "+id;
		}
	}
}

